home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / wgdb-42.lha / wgdb-4.2 / bfd / newsos3.c < prev    next >
C/C++ Source or Header  |  1992-09-11  |  6KB  |  175 lines

  1. /* BFD back-end for NewsOS3 (Sony, 68k) binaries.
  2.    Copyright (C) 1990-1991 Free Software Foundation, Inc.
  3.  
  4. This file is part of BFD, the Binary File Descriptor library.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #define    PAGE_SIZE    4096
  21. #define    SEGMENT_SIZE    PAGE_SIZE
  22. #define TEXT_START_ADDR 0
  23. #define ARCH 32
  24. #define BYTES_IN_WORD 4
  25.  
  26. #include "bfd.h"
  27. #include "sysdep.h"
  28. #include "libbfd.h"
  29. #include "aout64.h"
  30.  
  31. #undef N_TXTOFF
  32. #define N_TXTOFF(x)   ( (N_MAGIC((x)) == ZMAGIC) ? PAGE_SIZE : EXEC_BYTES_SIZE)
  33.  
  34. #include "stab.gnu.h"
  35. #include "ar.h"
  36. #include "libaout.h"           /* BFD a.out internal data structures */
  37.  
  38. bfd_target *newsos3_callback ();
  39.  
  40. bfd_target *
  41. DEFUN(newsos3_object_p,(abfd),
  42.      bfd *abfd)
  43. {
  44.   struct external_exec exec_bytes;
  45.   struct internal_exec exec;
  46.  
  47.   if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
  48.       != EXEC_BYTES_SIZE) {
  49.     bfd_error = wrong_format;
  50.     return 0;
  51.   }
  52.  
  53.   exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
  54.  
  55.   if (N_BADMAG (exec)) return 0;
  56.  
  57.   NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
  58.   return aout_32_some_aout_object_p (abfd, &exec, newsos3_callback);
  59. }
  60.  
  61. /* Finish up the reading of a NEWS-OS a.out file header */
  62. bfd_target *
  63. DEFUN(newsos3_callback,(abfd),
  64.       bfd *abfd)
  65. {
  66.   struct internal_exec *execp = exec_hdr (abfd);
  67.   
  68.   WORK_OUT_FILE_POSITIONS(abfd, execp) ;
  69.   
  70.   /* Determine the architecture and machine type of the object file.
  71.    */
  72.   bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0);
  73.  
  74.   adata(abfd)->page_size = PAGE_SIZE;
  75.   adata(abfd)->segment_size = SEGMENT_SIZE;
  76.   adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE;
  77.  
  78.   return abfd->xvec;
  79. }
  80.  
  81. static boolean
  82. DEFUN(newsos_mkobject,(abfd),
  83.       bfd *abfd)
  84. {
  85.     if (aout_32_mkobject(abfd) == false)
  86.     return false;
  87.     adata(abfd)->page_size = PAGE_SIZE;
  88.     adata(abfd)->segment_size = SEGMENT_SIZE;
  89.     adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE;
  90.     return true;
  91. }
  92.  
  93. /* Write an object file in NEWS-OS format.
  94.    Section contents have already been written.  We write the
  95.    file header, symbols, and relocation.  */
  96.  
  97. boolean
  98. DEFUN(newsos3_write_object_contents,(abfd),
  99.       bfd *abfd)
  100. {
  101.   bfd_size_type data_pad = 0;
  102.   struct external_exec exec_bytes;
  103.   struct internal_exec *execp = exec_hdr (abfd);
  104.  
  105.   WRITE_HEADERS(abfd, execp);
  106.   return true;
  107. }
  108.  
  109.  
  110. /* Transfer vectors for NEWS-OS version 3 */
  111.  
  112. /* We use BFD generic archive files.  */
  113. #define    newsos_openr_next_archived_file    bfd_generic_openr_next_archived_file
  114. #define    newsos_generic_stat_arch_elt    bfd_generic_stat_arch_elt
  115. #define    newsos_slurp_armap        bfd_slurp_bsd_armap
  116. #define    newsos_slurp_extended_name_table    bfd_true
  117. #define    newsos_write_armap        bsd_write_armap
  118. #define    newsos_truncate_arname        bfd_bsd_truncate_arname
  119.  
  120. /* We don't support core files yet.  FIXME.  */
  121. #define    newsos_core_file_failing_command    _bfd_dummy_core_file_failing_command
  122. #define    newsos_core_file_failing_signal    _bfd_dummy_core_file_failing_signal
  123. #define    newsos_core_file_matches_executable_p    \
  124.                 _bfd_dummy_core_file_matches_executable_p
  125. #define    newsos_core_file_p        _bfd_dummy_target
  126.  
  127. #define newsos_bfd_debug_info_start        bfd_void
  128. #define newsos_bfd_debug_info_end        bfd_void
  129. #define newsos_bfd_debug_info_accumulate    (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
  130.  
  131. #define newsos_close_and_cleanup aout_32_close_and_cleanup 
  132. #define newsos_set_section_contents aout_32_set_section_contents 
  133. #define newsos_get_section_contents aout_32_get_section_contents 
  134. #define newsos_new_section_hook aout_32_new_section_hook 
  135. #define newsos_get_symtab_upper_bound aout_32_get_symtab_upper_bound 
  136. #define newsos_get_symtab aout_32_get_symtab 
  137. #define newsos_get_reloc_upper_bound aout_32_get_reloc_upper_bound 
  138. #define newsos_canonicalize_reloc aout_32_canonicalize_reloc 
  139. #define newsos_make_empty_symbol aout_32_make_empty_symbol 
  140. #define newsos_print_symbol aout_32_print_symbol 
  141. #define newsos_get_lineno aout_32_get_lineno 
  142. #define newsos_set_arch_mach aout_32_set_arch_mach 
  143. #define newsos_find_nearest_line aout_32_find_nearest_line 
  144. #define newsos_sizeof_headers aout_32_sizeof_headers 
  145.  
  146.  
  147. /* We define our own versions of these routines.  */
  148.  
  149.  
  150. bfd_target newsos3_vec = /* Sony 68k-based machines running newsos3 */
  151. {
  152.   "a.out-newsos3",        /* name */
  153.   bfd_target_aout_flavour,
  154.   true,                /* target byte order */
  155.   true,                /* target headers byte order */
  156.   (HAS_RELOC | EXEC_P |        /* object flags */
  157.    HAS_LINENO | HAS_DEBUG |
  158.    HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
  159.   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
  160.   ' ',                /* ar_pad_char */
  161.   16,                /* ar_max_namelen */
  162.   1,                /* minimum alignment */
  163.   _do_getb64, _do_putb64,    _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
  164.   _do_getb64, _do_putb64,    _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
  165.  
  166.     {_bfd_dummy_target, newsos3_object_p, /* bfd_check_format */
  167.        bfd_generic_archive_p, newsos_core_file_p},
  168.     {bfd_false, newsos_mkobject,    /* bfd_set_format */
  169.        _bfd_generic_mkarchive, bfd_false},
  170.     {bfd_false, newsos3_write_object_contents, /* bfd_write_contents */
  171.        _bfd_write_archive_contents, bfd_false},
  172.  
  173.   JUMP_TABLE(newsos)
  174. };
  175.